package com.evan.webadmin.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.evan.webadmin.biz.dao.EvluateSurveyDetailMapper;
import com.evan.webadmin.biz.model.EvluateSurveyDetail;
import com.evan.webadmin.biz.service.IEvluateSurveyDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 评价问卷详情表 服务实现类
 * </p>
 *
 * @author Pavel
 * @since 2025-03-04
 */
@Service
public class EvluateSurveyDetailServiceImpl extends ServiceImpl<EvluateSurveyDetailMapper, EvluateSurveyDetail> implements IEvluateSurveyDetailService {

    @Autowired
    EvluateSurveyDetailMapper evluateSurveyDetailMapper;

    @Override
    public List<EvluateSurveyDetail> detail(Long surveyId) {
        QueryWrapper<EvluateSurveyDetail> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("survey_id", surveyId);
        return evluateSurveyDetailMapper.selectList(queryWrapper);
    }

    @Override
    public Long subjectUseAble(long subjectId) {
        QueryWrapper<EvluateSurveyDetail> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("subject_id", subjectId);
        queryWrapper.eq("delete_flag", 0L);
        return evluateSurveyDetailMapper.selectCount(queryWrapper);
    }
}
